using System;
using System.Configuration;
namespace RomanJendrusz.Amazon.ETL
{
    public class AmazonConstants
    {
        public static DateTime OlderEntityDate
        {
            get
            {
                var updateEntityAfterDays = ConfigurationManager.AppSettings["UpdateEntityAfterDays"];
                int numberOfDays;
                try
                {
                    numberOfDays = Int32.Parse(updateEntityAfterDays);
                }
                catch (Exception e)
                {
                    throw new ConfigurationErrorsException("The UpdateEntityAfterDays keys value in the configuration file is invalid");
                }
                return DateTime.Now.AddDays(0 - numberOfDays);
            }
        }

        public static int SimilarBooksHierarchyDepth
        {
            get
            {
                var similarBooksHierarchyDepth = ConfigurationManager.AppSettings["SimilarBooksHierarchyDepth"];
                int depth;
                try
                {
                    depth= Int32.Parse(similarBooksHierarchyDepth);
                }
                catch (Exception e)
                {
                    throw new ConfigurationErrorsException("The SimilarBooksHierarchyDepth keys value in the configuration file is invalid");
                }
                return depth;   
            }
        }
    }
}